import java.util.ArrayList;
import java.util.List;

/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: 26727
 * Date: 2025-08-17
 * Time: 16:01
 */
public class Test84 {
    public static List<List<Integer>> generate(int numRows) {
        List<List<Integer>> ret = new ArrayList<>();
        List<Integer> row = new ArrayList<>();

        row.add(1);
        ret.add(row);

        for(int i = 1; i < numRows; i++) {
            List<Integer> curRow = new ArrayList<>();
            List<Integer> preRow = ret.get(i-1);
            curRow.add(1);
            for(int j = 1; j < i; j++) {
                curRow.add(preRow.get(j)+preRow.get(j-1));
            }
            curRow.add(1);
            ret.add(curRow);
        }
        return ret;
    }

    public static void main(String[] args) {
        int n = 5;
        List<List<Integer>> ret = generate(n);
        System.out.println(ret);
    }
}
